<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.2">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/avatar.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/avatar.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/avatar.png">
  <link rel="mask-icon" href="/images/avatar.png" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"notes.maxwi.com","root":"/","scheme":"Mist","version":"7.8.0","exturl":false,"sidebar":{"position":"right","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":true,"color":"#222","save":"auto"},"fancybox":true,"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":true,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":false,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="tmux主要的功能有两点：  终端利用，可以在一个terminal开启多个shell的session，这样就不需要vim一个terminal，命令又要需要一个，其他服务还要再开一个了。 断线保证任务在后台继续执行，以及当你上线后保证原来打开的多个窗口与断线之前完全一样。以后就不用再使用screen了">
<meta property="og:type" content="article">
<meta property="og:title" content="tmux简洁教程">
<meta property="og:url" content="http://notes.maxwi.com/2017/11/10/tmux/index.html">
<meta property="og:site_name" content="blueyi&#39;s notes">
<meta property="og:description" content="tmux主要的功能有两点：  终端利用，可以在一个terminal开启多个shell的session，这样就不需要vim一个terminal，命令又要需要一个，其他服务还要再开一个了。 断线保证任务在后台继续执行，以及当你上线后保证原来打开的多个窗口与断线之前完全一样。以后就不用再使用screen了">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2017-11-10T08:31:54.000Z">
<meta property="article:modified_time" content="2017-11-10T08:31:54.000Z">
<meta property="article:author" content="blueyi">
<meta property="article:tag" content="Linux">
<meta property="article:tag" content="tmux">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://notes.maxwi.com/2017/11/10/tmux/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'en'
  };
</script>

  <title>tmux简洁教程 | blueyi's notes</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="blueyi's notes" type="application/atom+xml">
<link rel="alternate" href="/rss2.xml" title="blueyi's notes" type="application/rss+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Toggle navigation bar">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">blueyi's notes</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Follow Excellence,Success will chase you!</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>Home</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>Categories</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>Archives</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>Tags</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>About</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>Search
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="Searching..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>
  <a role="button" class="book-mark-link book-mark-link-fixed"></a>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
    <link itemprop="mainEntityOfPage" href="http://notes.maxwi.com/2017/11/10/tmux/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/default_avatar.jpg">
      <meta itemprop="name" content="blueyi">
      <meta itemprop="description" content="心怀善意，虛怀若谷！">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="blueyi's notes">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          tmux简洁教程
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>

              <time title="Created: 2017-11-10 16:31:54" itemprop="dateCreated datePublished" datetime="2017-11-10T16:31:54+08:00">2017-11-10</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">In</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Linux/" itemprop="url" rel="index"><span itemprop="name">Linux</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="Symbols count in article">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">Symbols count in article: </span>
              <span>4k</span>
            </span>
            <span class="post-meta-item" title="Reading time">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">Reading time &asymp;</span>
              <span>4 mins.</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>tmux主要的功能有两点：</p>
<ul>
<li>终端利用，可以在一个terminal开启多个shell的session，这样就不需要vim一个terminal，命令又要需要一个，其他服务还要再开一个了。</li>
<li>断线保证任务在后台继续执行，以及当你上线后保证原来打开的多个窗口与断线之前完全一样。以后就不用再使用screen了</li>
</ul>
<span id="more"></span>

<p>两个功能都非常棒，值得花点时间学习，分分钟就能掌握基本应用。<br><code>tmux</code>中有三个最基本的概念： <strong>会话（session）、窗口（window）、窗格（Pane）</strong><br>当开启tmux后，它首先会创建一个会话，在会话中会首先创建一个窗口，窗口中会创建一个面板，一个面板就可以当成一个我们可以使用的shell窗口。<br>下面会混用窗格和面板，都指pane</p>
<p><code>tmux</code>使用<code>C/S</code>模型，主要包含以下模块：</p>
<ul>
<li>server服务器。输入tmux命令时就开启了一个服务器。</li>
<li>session会话。一个服务器可以包含多个会话</li>
<li>window窗口。一个会话可以包含多个窗口。</li>
<li>pane面板。一个窗口可以包含多个面板。</li>
</ul>
<h2 id="基本应用"><a href="#基本应用" class="headerlink" title="基本应用"></a>基本应用</h2><p><strong>启动tmux</strong><br>安装后在命令行输入<code>tmux</code>就启动了，看到只有一个窗口，窗口下方会有基本状态信息。<br><code>tmux</code>的使用可以完全靠快捷键，快捷键以前缀快捷键+快捷键构成，默认的前缀（prefix）快捷键是<code>ctrl-b</code>，用法是按下<code>Ctrl-b</code>，放开后再按下相应的快键即可，例如查看<code>tmux</code>会话的快捷键是s，可以按下<code>ctrl-b</code>，放开再按<code>s</code>，即可查看当前的所有会话。<br>知道怎么按快捷键也就会有tmux了，下面试一下纵向分隔窗口的快捷键：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">prefix %</span><br></pre></td></tr></table></figure>
<p>横向分隔窗口：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">prefix &quot;</span><br></pre></td></tr></table></figure>
<p>窗口间切换<code>prefix &lt;相应方向键&gt;</code><br>这样你就可以在一个terminal中即开多个vim，又进行其他操作了。<br>希望这些切换可以像vim的快捷键一样？看后面的配置</p>
<p><strong>退出或关闭tmux</strong><br>当要退出tmux时可以使用<code>exit</code>，这样会关闭当前的tmux面板，当所有面板关闭时也就退出了窗口。<br>如果要让它在后台运行，你要先回到普通的terminal，使用快捷键<code>prefix &amp;</code>。<br>想再回来，比如断线重连时，可以使用<code>tmux attach</code>，或者直接<code>tmux a</code>，可以可看其常用命令获取更多内容。<br>要关闭整个tmux服务的话使用<code>tmux kill-server</code><br>查看版本：<code>tmux -V</code></p>
<p><strong>会话相关命令</strong><br><code>tmux new -s [session_name]</code>  创新新会话<br><code>tmux new -s [session_name] -d</code> 在后台建立会话<br><code>tmux ls</code> 列出会话<br><code>tmux attach -t [session_name]</code> 进入某个会话<br>或者在tmux中使用命令<code>prefix :new-session</code>新一个会话</p>
<h3 id="复制面板中的内容"><a href="#复制面板中的内容" class="headerlink" title="复制面板中的内容"></a>复制面板中的内容</h3><ul>
<li><code>prefix [</code> 进入复制模式</li>
<li>按 <code>space</code> 开始复制，移动光标选择复制区域</li>
<li>按 <code>Enter</code> 复制并退出复制模式。</li>
<li>将光标移动到指定位置，按 <code>prefix ]</code> 粘贴</li>
</ul>
<h2 id="常用快捷键"><a href="#常用快捷键" class="headerlink" title="常用快捷键"></a>常用快捷键</h2><p>注意窗格是指Pane，窗口是指window</p>
<ul>
<li><code>C-b ?</code> 显示快捷键帮助</li>
<li><code>C-b :</code> 进入命令模式</li>
<li><code>C-b C-z</code> 挂起会话，不影响其他命令的运行</li>
<li><code>C-b C-o</code> 调换窗格位置，类似与vim 里的C-w</li>
<li><code>C-b 空格键</code> 采用下一个内置布局</li>
<li><code>C-b !</code> 把当前窗格（pane）变为新窗口（window）</li>
<li><code>C-b &quot;</code> 横向分隔窗格</li>
<li><code>C-b %</code> 纵向分隔窗格</li>
<li><code>C-b q</code> 显示分隔窗格的编号</li>
<li><code>C-b o</code> 跳到下一个分隔窗格</li>
<li><code>C-b 上下键</code> 上一个及下一个分隔窗格</li>
<li><code>C-b C-方向键</code> 调整分隔窗格大小，注意C表示Ctrl键</li>
<li><code>C-b z</code> 最大化当前窗格，再一次则恢复</li>
<li><code>C-b c</code> 创建新窗口</li>
<li><code>C-b 0~9</code> 选择几号窗口</li>
<li><code>C-b n</code> 选择下一个窗口</li>
<li><code>C-b p</code> 选择前一个窗口</li>
<li><code>C-b l</code> 切换到前一个窗口，该快捷键通常会被重定义为符合vim下的空格切换</li>
<li><code>C-b w</code> 以菜单方式显示及选择窗口</li>
<li><code>C-b s</code> 以菜单方式显示和选择会话</li>
<li><code>C-b t</code> 显示时钟</li>
<li><code>C-b ;</code> 切换到最后一个使用的面板</li>
<li><code>C-b x</code> 关闭面板</li>
<li><code>C-b &amp;</code> 关闭窗口</li>
<li><code>C-b d</code> 退出tumx，并保存当前会话，这时，tmux仍在后台运行，可以通过tmux attach进入 到指定的会话</li>
</ul>
<p>tmux中很多需要移动光标的地方都支持vim的<code>i,j,k,h</code>，可以自行试试</p>
<h2 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h2><p>为了让tmux更加好用，就像vim一样，我们需要进行一些个性化的配置。tmux的系统级配置文件在<code>/etc/tmux.conf</code>，用户级配置文件可以放在<code>~/.tmux.conf</code><br>下面给出一份我自己在使用的，主要是针对vim的使用习惯进行了一些键绑定，增加了2个插件，功能内容都有注释：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><span class="line"># rebind prefix key</span><br><span class="line">unbind C-b</span><br><span class="line">set -g prefix C-x</span><br><span class="line"></span><br><span class="line"># bind a reload key for tmux configure</span><br><span class="line">bind r source-file ~/.tmux.conf \; display &quot;Config reloaded..&quot;</span><br><span class="line"></span><br><span class="line"># Use vim keybindings in copy mode</span><br><span class="line">setw -g mode-keys vi</span><br><span class="line"></span><br><span class="line"># Select text like vim</span><br><span class="line">bind -t vi-copy &#x27;v&#x27; begin-selection</span><br><span class="line">bind -t vi-copy &#x27;y&#x27; copy-selection</span><br><span class="line">bind -t vi-copy &#x27;Space&#x27; halfpage-down</span><br><span class="line">bind -t vi-copy &#x27;Bspace&#x27; halfpage-up</span><br><span class="line"></span><br><span class="line"># Switch pane use vi key bind</span><br><span class="line">bind-key k select-pane -U # up</span><br><span class="line">bind-key j select-pane -D # down</span><br><span class="line">bind-key h select-pane -L # left</span><br><span class="line">bind-key l select-pane -R # right</span><br><span class="line"></span><br><span class="line"># Adjust pane by mouse</span><br><span class="line">set -g mouse on</span><br><span class="line"></span><br><span class="line"># plugin</span><br><span class="line"># Tmux Plugin Manager</span><br><span class="line"># git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm</span><br><span class="line">set -g @plugin &#x27;tmux-plugins/tpm&#x27;</span><br><span class="line"></span><br><span class="line"># basic tmux settings everyone can agree on</span><br><span class="line">set -g @plugin &#x27;tmux-plugins/tmux-sensible&#x27;</span><br><span class="line"></span><br><span class="line"># Persists tmux environment across system restarts.</span><br><span class="line">run-shell ~/.tmux/tmux-resurrect/resurrect.tmux</span><br><span class="line">set -g @plugin &#x27;tmux-plugins/tmux-resurrect&#x27;</span><br><span class="line"></span><br><span class="line"># Continuous saving of tmux environment. Automatic restore when tmux is started. Automatic tmux start when computer is turned on.</span><br><span class="line">set -g @plugin &#x27;tmux-plugins/tmux-continuum&#x27;</span><br><span class="line">set -g @continuum-save-interval &#x27;60&#x27;</span><br><span class="line"></span><br><span class="line"># Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)</span><br><span class="line">run &#x27;~/.tmux/plugins/tpm/tpm&#x27;</span><br></pre></td></tr></table></figure>

<p>修改完配置文件之后可以在tmux中按快捷键<code>Ctrl-b :</code>进入命令模式，输入<code>source-file ~/.tmux.conf</code>，使其生效。经过上述配置文件之后，以后修改完配置文件直接使用<code>Ctrl-b r</code>就可以重新加载新配置文件了。<br>如果是在terminal中，使用命令<code>tmux source-file ~/.tmux.conf</code>使配置生效。</p>
<h2 id="插件"><a href="#插件" class="headerlink" title="插件"></a>插件</h2><p>这里主要推荐4个插件，确切来说是2组。<br><strong>tpm</strong><br>用于管理tmux插件，类似与vim下的vundle<br>地址：<a target="_blank" rel="noopener" href="https://github.com/tmux-plugins/tpm">https://github.com/tmux-plugins/tpm</a></p>
<p><strong>tmux-sensible</strong><br>一些tmux的基本配置，适合几乎所有人，可以看一下它的配置内容<br>地址：<a target="_blank" rel="noopener" href="https://github.com/tmux-plugins/tmux-sensible">https://github.com/tmux-plugins/tmux-sensible</a></p>
<p><strong>tmux-resurrect</strong><br>用户保存和恢复tmux的运行环境，非常好用，当你需要对当前你打开的tmux的会话、窗口、空格以及其位置保存时，直接按快捷键<code>prefix Ctrl-s</code>即可保存，需要恢复时是<code>prefix Ctrl-r</code>。<br>地址：<a target="_blank" rel="noopener" href="https://github.com/tmux-plugins/tmux-resurrect">https://github.com/tmux-plugins/tmux-resurrect</a></p>
<p><strong>tmux-continuum</strong><br>可以用于配合tmux-recurrect，它会自动化地帮你保存和恢复<br>地址：<a target="_blank" rel="noopener" href="https://github.com/tmux-plugins/tmux-continuum">https://github.com/tmux-plugins/tmux-continuum</a></p>
<h2 id="其他问题"><a href="#其他问题" class="headerlink" title="其他问题"></a>其他问题</h2><h3 id="会话的命令行操作"><a href="#会话的命令行操作" class="headerlink" title="会话的命令行操作"></a>会话的命令行操作</h3><table>
<thead>
<tr>
<th>命令</th>
<th>功能</th>
</tr>
</thead>
<tbody><tr>
<td><code>tmux ls</code></td>
<td># 显示所有会话</td>
</tr>
<tr>
<td><code>tmux new -s &lt;session-name&gt;</code></td>
<td>#新建会话，并指定会话名</td>
</tr>
<tr>
<td><code>tmux new</code></td>
<td># 新建会话，会话名自动为数字序号</td>
</tr>
<tr>
<td><code>tmux a</code></td>
<td># 接入上一个会话</td>
</tr>
<tr>
<td><code>tmux a -t &lt;session-name&gt;</code></td>
<td># 接入指定会话</td>
</tr>
<tr>
<td><code>tmux detach</code></td>
<td># 断开当前会话，等价于ctrl+b d</td>
</tr>
<tr>
<td><code>tmux kill-session -t &lt;session-name&gt;</code></td>
<td># 关闭指定会话</td>
</tr>
<tr>
<td><code>tmux kill-session -a -t &lt;session-name&gt;</code></td>
<td>#关闭除指定会话外的其他所有会话</td>
</tr>
<tr>
<td><code>tmux kill-server</code></td>
<td># 销毁所有会话并停止tmux</td>
</tr>
</tbody></table>
<h2 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h2><ol>
<li><a target="_blank" rel="noopener" href="http://blog.csdn.net/ZCF1002797280/article/details/51859524">tmux使用及个性化配置
</a></li>
<li>[StackOverFlow]</li>
<li>[man tmux]</li>
</ol>

    </div>

    
    
    
        

  <div class="followme">
    <p>Welcome to my other publishing channels</p>

    <div class="social-list">

        <div class="social-item">
          <a target="_blank" class="social-link" href="/atom.xml">
            <span class="icon">
              <i class="fa fa-rss"></i>
            </span>

            <span class="label">RSS</span>
          </a>
        </div>
    </div>
  </div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/Linux/" rel="tag"># Linux</a>
              <a href="/tags/tmux/" rel="tag"># tmux</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2017/11/09/makefile/" rel="prev" title="Makefile极简教程">
      <i class="fa fa-chevron-left"></i> Makefile极简教程
    </a></div>
      <div class="post-nav-item">
    <a href="/2017/11/29/gtest/" rel="next" title="Google Test(gtest)使用">
      Google Test(gtest)使用 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    <div class="comments" id="gitalk-container"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          Table of Contents
        </li>
        <li class="sidebar-nav-overview">
          Overview
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%9F%BA%E6%9C%AC%E5%BA%94%E7%94%A8"><span class="nav-number">1.</span> <span class="nav-text">基本应用</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%A4%8D%E5%88%B6%E9%9D%A2%E6%9D%BF%E4%B8%AD%E7%9A%84%E5%86%85%E5%AE%B9"><span class="nav-number">1.1.</span> <span class="nav-text">复制面板中的内容</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%B8%B8%E7%94%A8%E5%BF%AB%E6%8D%B7%E9%94%AE"><span class="nav-number">2.</span> <span class="nav-text">常用快捷键</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E9%85%8D%E7%BD%AE"><span class="nav-number">3.</span> <span class="nav-text">配置</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%8F%92%E4%BB%B6"><span class="nav-number">4.</span> <span class="nav-text">插件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%85%B6%E4%BB%96%E9%97%AE%E9%A2%98"><span class="nav-number">5.</span> <span class="nav-text">其他问题</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BC%9A%E8%AF%9D%E7%9A%84%E5%91%BD%E4%BB%A4%E8%A1%8C%E6%93%8D%E4%BD%9C"><span class="nav-number">5.1.</span> <span class="nav-text">会话的命令行操作</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8F%82%E8%80%83"><span class="nav-number">6.</span> <span class="nav-text">参考</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="blueyi"
      src="/images/default_avatar.jpg">
  <p class="site-author-name" itemprop="name">blueyi</p>
  <div class="site-description" itemprop="description">心怀善意，虛怀若谷！</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">104</span>
          <span class="site-state-item-name">posts</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">26</span>
        <span class="site-state-item-name">categories</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">68</span>
        <span class="site-state-item-name">tags</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/blueyi" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;blueyi" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title"><i class="fa fa-link fa-fw"></i>
      Links
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <a href="http://maxwi.com/" title="http:&#x2F;&#x2F;maxwi.com" rel="noopener" target="_blank">Maxwi</a>
        </li>
    </ul>
  </div>

      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 2014 – 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">blueyi</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-area"></i>
    </span>
    <span title="Symbols count total">750k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="Reading time total">11:22</span>
</div>
  <div class="powered-by">Powered by <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://mist.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Mist</a>
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/pjax/pjax.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js"></script>
  <script src="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/lozad@1/dist/lozad.min.js"></script>

<script src="/js/utils.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>

<script src="/js/bookmark.js"></script>

  <script>
var pjax = new Pjax({
  selectors: [
    'head title',
    '#page-configurations',
    '.content-wrap',
    '.post-toc-wrap',
    '.languages',
    '#pjax'
  ],
  switches: {
    '.post-toc-wrap': Pjax.switches.innerHTML
  },
  analytics: false,
  cacheBust: false,
  scrollTo : !CONFIG.bookmark.enable
});

window.addEventListener('pjax:success', () => {
  document.querySelectorAll('script[data-pjax], script#page-configurations, #pjax script').forEach(element => {
    var code = element.text || element.textContent || element.innerHTML || '';
    var parent = element.parentNode;
    parent.removeChild(element);
    var script = document.createElement('script');
    if (element.id) {
      script.id = element.id;
    }
    if (element.className) {
      script.className = element.className;
    }
    if (element.type) {
      script.type = element.type;
    }
    if (element.src) {
      script.src = element.src;
      // Force synchronous loading of peripheral JS.
      script.async = false;
    }
    if (element.dataset.pjax !== undefined) {
      script.dataset.pjax = '';
    }
    if (code !== '') {
      script.appendChild(document.createTextNode(code));
    }
    parent.appendChild(script);
  });
  NexT.boot.refresh();
  // Define Motion Sequence & Bootstrap Motion.
  if (CONFIG.motion.enable) {
    NexT.motion.integrator
      .init()
      .add(NexT.motion.middleWares.subMenu)
      .add(NexT.motion.middleWares.postList)
      .bootstrap();
  }
  NexT.utils.updateSidebarPosition();
});
</script>




  
  <script data-pjax>
    (function(){
      var canonicalURL, curProtocol;
      //Get the <link> tag
      var x=document.getElementsByTagName("link");
		//Find the last canonical URL
		if(x.length > 0){
			for (i=0;i<x.length;i++){
				if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
					canonicalURL=x[i].href;
				}
			}
		}
    //Get protocol
	    if (!canonicalURL){
	    	curProtocol = window.location.protocol.split(':')[0];
	    }
	    else{
	    	curProtocol = canonicalURL.split(':')[0];
	    }
      //Get current URL if the canonical URL does not exist
	    if (!canonicalURL) canonicalURL = window.location.href;
	    //Assign script content. Replace current URL with the canonical URL
      !function(){var e=/([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi,r=canonicalURL,t=document.referrer;if(!e.test(r)){var n=(String(curProtocol).toLowerCase() === 'https')?"https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif":"//api.share.baidu.com/s.gif";t?(n+="?r="+encodeURIComponent(document.referrer),r&&(n+="&l="+r)):r&&(n+="?l="+r);var i=new Image;i.src=n}}(window);})();
  </script>




  
<script src="/js/local-search.js"></script>













    <div id="pjax">
  

  

<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.css">

<script>
NexT.utils.loadComments(document.querySelector('#gitalk-container'), () => {
  NexT.utils.getScript('//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js', () => {
    var gitalk = new Gitalk({
      clientID    : '0f8243eb2c8b2207980f',
      clientSecret: 'd159633a33519d3b7a48b0ca729032f7d1f38a41',
      repo        : 'notes',
      owner       : 'blueyi',
      admin       : ['blueyi'],
      id          : 'c4f6455201aeb9118f850f1b009e5761',
        language: '',
      distractionFreeMode: true
    });
    gitalk.render('gitalk-container');
  }, window.Gitalk);
});
</script>

    </div>
</body>
</html>
